<?php
require_once 'Stomp.php';
require_once 'Stomp/Message.php';
require_once 'Stomp/Message/Map.php';

class MessageHelper {
	static public function sendMessage($broker, $queue, $map) {
		$con = new Stomp($broker);
		$con->connect();

		$header = array("compression" => "bzip");
        $json = json_encode($map);
        $bzip = bzcompress($json,9);
        $base64 = base64_encode($bzip);
        $message = new Stomp_Message_Map($base64, $header);

		$ret = $con->send($queue, $message, array('persistent' => 'true'), true);

		$con->disconnect();

		return $ret;
	}
}

?>
